<style scoped lang="less">
.page-index {
  overflow: auto;
}
.page-box {
  text-align: center;
  margin: 20px auto;
}
</style>
<template>
    <div class="page-index">
        <i-table stripe  border  :columns="columns" :data="data"></i-table>
        <!--分页内容-->
        <div class="page-box">
            <Page :total="pageTotal" @on-change="pageChange" :page-size="pageSize" show-elevator></Page>
        </div>
    </div>
</template>
<script>
export default {
  data() {
    return {
      pageIndex: 0,
      pageSize: 10,
      pageTotal: 0,
      columns: [
        {
          title: "姓名",
          key: "name"
        },
        {
          title: "工号",
          key: "num"
        },
        {
          title: "祝福话语",
          key: "bless"
        },
        {
          title: "签到状态",
          key: "sign",
          filters: [
            {
              label: "已签到",
              value: true
            },
            {
              label: "未签到",
              value: false
            }
          ],
          filterMultiple: false,
          filterMethod(value, row) {
            if (value) {
              return row.sign == true;
            } else {
              return row.sign != true;
            }
          },
          render: (h, params) => {
            return h("div", params.row.sign == true ? "已签到" : "未签到");
          }
        }
      ],
      data: []
    };
  },
  created() {
    var self = this;
    self.init();
  },
  methods: {
    init() {
      var self = this;

      var req = this.Axios.get(this.Interface.signList, {
        params: {
          pageIndex: this.pageIndex,
          pageSize: this.pageSize
        }
      });

      req.then(res => {
        var data = res.data;
        console.log(data);
        if (data.success) {
          var count = data.data.count;
          this.pageTotal = count;
          this.data = data.data.rows;
        } else {
          this.$Message.error(data.msg);
        }
      });
    },
    pageChange() {
      var pageNum = arguments[0];
      this.pageIndex = pageNum - 1;
      this.init();
    }
  }
};
</script>
